package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.Month;
import java.util.Date;
import java.util.List;

@Mapper
public interface OrderSettingMapper {
    /**
     *根据预约时间查可预约人数
     * @param beginDate
     * @return
     */
    @Select("select number from ordersetting where orderDate=#{beginDate}")
    Integer getNumberByDate(LocalDate beginDate);

    /**
     * 查询一共有多少数据
     */
    @Select("select id from ordersetting")
    List<Integer> getId();

    /**
     * 根据id查询对应日期
     * @param firstId
     * @return
     */  @Select("select orderDate from ordersetting where id =#{firstId}")
    LocalDate getDayById(Integer firstId);

    /**
     * 更新数据库
     * @param orderSetting
     */
    void updateByOrderDate(OrderSetting orderSetting);

    /**
     * 根据年月查询对应的预约设置信息
     * @param year
     * @param yearOfMonth
     * @return
     */
    @Select("SELECT  * FROM ordersetting WHERE year(orderDate) = #{year} AND month(orderDate) = #{yearOfMonth}")
    List<OrderSetting> getOrderSetting(int year, Month yearOfMonth);

    /**
     *根据日期查询数据是否存在
     * @param orderSetting
     */
    @Select("SELECT  * FROM ordersetting WHERE orderDate=#{orderDate}")
    List<OrderSetting> selectByOrderDate(OrderSetting orderSetting);

    /**
     *添加数据
     * @param orderSetting
     */
    void insert(OrderSetting orderSetting);

}
